<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .login {
            position: absolute;
            width: 200px;
            height: 200px;
            background-color: palegoldenrod;
        }
    </style>
</head>
<body>
    <div class="login"></div>
    <script>
        let div = document.querySelector('.login');
        console.log(div.offsetTop,div.offsetLeft);
        div.addEventListener('mousedown',function (e){
            let x = e.pageX - div.offsetLeft;
            let y = e.pageY - div.offsetTop;

            document.addEventListener('mousemove',move)
            function move(e) {
                div.style.left = e.pageX - x + 'px';
                div.style.top = e.pageY - y + 'px';
            }

            document.addEventListener('mouseup',function () {
                document.removeEventListener('mousemove', move);
            })
        })

    </script>
</body>
</html>